package com.e3.basdoc.region.service;

import java.util.List;

import com.e3.basdoc.region.model.RegionModel;
import com.e3.core.base.ServiceLocator;
import com.e3.core.cache.CacheLoader;

public class RegionCacheLoader implements CacheLoader {
	
	private RegionQueryService queryService;
	
	public RegionQueryService getQueryService() {
		if(queryService == null){
			queryService = ServiceLocator.getQueryService(RegionQueryService.class);
		}
		return queryService;
	}

	public void loadeData() throws Exception{
		List<RegionModel> models = getQueryService().getAllRegions();
		if(models==null||models.isEmpty()){
			return;
		}
		for (RegionModel regionModel : models) {
			RegionCacheManager.INSTANCE.put(regionModel);
		}
	}

}
